Brief Full Advanced Search Search Tips
|  |  | To access the contents, click the chapter and section titles. Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6! (Publisher: The Coriolis Group) Author(s): Peter G. Aitken ISBN: 1576102815 Publication Date: 08/01/98 Search this book:
Previous | Table of Contents | Next
### Other Visual Design You should know a few other visual design tricks: • You can overlap controls. Normally, the one that was placed on the form first will be totally or partially hidden by the one that was placed later. • You can modify the relationship of overlapped controls. Use the Bring to Front and Send to Back commands, both accessed by selecting Order from the Format menu. Bring to Front makes the selected control the top one in the “pile” of overlapping controls, so it will be visible and hide the other controls. Send to Back has the opposite effect. • Finally, you can lock the controls on a form to prevent them from being accidentally modified. Select the Lock Controls command on the Format menu, and all controls on the form—both existing ones and those you add subsequently—are locked and cannot be moved or resized. They can be deleted, however. Select the command again to unlock the controls. When locked, selected controls display white handles. TIP: A Toolbar For All Reasons The Form Editor toolbar displays buttons for common design tasks, such as control alignment and sizing. To display this toolbar (or hide it again), select View|Toolbars|Form Editor. ### A Control Gallery Now that you know how to place and arrange controls on a form, it’s time for a brief overview of some of the controls that Visual Basic provides. This is not intended to be a detailed summary of the entire Visual Basic control set. My goal is simply to make you aware of the most fundamental of the controls, those that are used most often. You’ll be meeting the other controls later in the book. Figure 3.2 illustrates the more commonly used Visual Basic controls. Commonly used Visual Basic controls include: • Command Button—Provides a way for the user to tell the program “go” or “start.” Its most typical use is to cause the program to take some action when the user clicks on the button or selects it using the keyboard. Figure 3.2 The most commonly used Visual Basic controls. • Text Box—Used for the display, input, and editing of text. A Text Box can display anything from a single word to a document containing hundreds of lines of text. You’ll find that the Text Box is one of Visual Basic’s most useful and powerful controls. • Check Box—Lets the user turn an option on or off. A Check Box consists of a small box with an adjacent label. Check Boxes toggle on and off: Clicking on the box or selecting it with the keyboard places (or removes) an X in the box. The program can query the Check Box’s Value property to see if it is in the on or off state. • Option Button—Similar to the Check Box in that it provides an option that the user can turn on or off. The difference is that Option Buttons are always arranged in groups of two or more, and only one option in the group can be on at any time. • Picture Box—Does just what its name suggests: It displays a picture. You can also create graphics in a Picture Box using Basic statements. The Picture Box control has a lot of hidden power that greatly simplifies the otherwise complex task of handling and displaying graphics and images. In Figure 3.2, the Picture Box displays as a blank rectangle because it has not yet been loaded with a picture. • Label—Perhaps the simplest control, with the main purpose of displaying fixed text on a form. Fixed means that the user cannot edit or modify the text, so Labels are generally used to identify other items on a form. • List Box—Displays a scrollable list of text items from which the user can select. With automatic sorting of its contents, a List Box is a common method of presenting a list of options, such as font names, to the user. • Combo Box—A combination of a Text Box and a List Box. It normally displays as a single-line Text Box, but clicking on its arrow opens a list of items from which the user can choose. This list includes only eight of Visual Basic’s controls, which are an integral part of the Visual Basic development environment and are always displayed in the toolbox. Visual Basic also supports custom controls, drop-in components that represent one of the foundations of the software component philosophy. Most custom controls are a special category of object called ActiveX controls. You can control which of the available custom controls are displayed in the toolbox by selecting Components from the Project menu and clicking on the Controls tab in the dialog box that is displayed. As shown in Figure 3.3, this tab lists all of the custom controls that you have available. Only those controls and objects with an X in the box next to their name will be displayed as buttons in the toolbox. While you can click on the boxes to turn the option on or off, you cannot remove a control that is used in your project (i.e., has been placed on a form). My system offers 39 custom controls, and displaying all of them all the time—along with the 20 intrinsic controls—would result in a confusing and unwieldy toolbox. In addition, many of the custom controls are rather specialized, so you can see why Visual Basic lets you determine which controls are displayed in the toolbox. Figure 3.3 The Controls tab in the Components dialog box. TIP: Which Controls Are Available? The controls listed in your Components dialog box will depend on what is installed on your system. Some controls are provided as part of Visual Basic, and which ones you have depends on the edition of Visual Basic you have. Other controls are part of other softw are packages. Don’t be concerned if your list of controls does not look like the one in Figure 3.3. What about the other two tabs in this dialog box? Both insertable objects and designers are like custom controls in two respects: They are software components that you can use in your Visual Basic projects, and they display as icons in the toolbox. How are they different? A custom control, or an ActiveX control, is a self-contained component that depends only on its OCX file. It has no use except for being dropped in a Visual Basic program (or a program being created with another development tool that supports custom controls). In contrast, an insertable object represents a data object that is supported by an existing application on your system. An insertable object is available to your Visual Basic programs only if the corresponding application is installed on your system. For example, you can create a chart in Microsoft Excel and then insert the chart into your Visual Basic program. People using your programs, however, will be able to use the inserted object only if they also have the application on their system.
Previous | Table of Contents | Next

| Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.